Completed
Push — master ( e3ee1d...5cbb1b )
by Justin
01:36
created

Gender.js ➔ describe(ꞌGenderꞌ)   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 57

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 57
rs 9.6818

5 Functions

Rating   Name   Duplication   Size   Complexity  
A Gender.js ➔ ... ➔ it(ꞌCreate with JSONꞌ) 0 14 1
A Gender.js ➔ ... ➔ it(ꞌtoJSONꞌ) 0 11 1
A Gender.js ➔ ... ➔ it(ꞌCreate plainꞌ) 0 6 1
A Gender.js ➔ ... ➔ it(ꞌBuildꞌ) 0 13 1
A Gender.js ➔ ... ➔ it(ꞌconstructor does not copy instancesꞌ) 0 5 1

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
var assert = require('chai').assert,
2
    GedcomX = require('../../');
3
4
describe('Gender', function(){
5
  
6
  it('Create plain', function(){
7
    var newGender = new GedcomX.Gender(),
8
        gender = GedcomX.Gender();
9
    assert.instanceOf(newGender, GedcomX.Gender, 'An instance of Gender is not returned when calling the constructor with new.');
10
    assert.instanceOf(gender, GedcomX.Gender, 'An instance of Gender is not returned when calling the constructor without new.');
11
  });
12
  
13
  it('Create with JSON', function(){
14
    var gender = GedcomX.Gender({
15
      id: 'gender',
16
      type: 'http://gedcomx.org/Male',
17
      confidence: 'http://gedcomx.org/High',
18
      attribution: {
19
        created: 1145667891
20
      }
21
    });
22
    assert.equal(gender.getId(), 'gender');
23
    assert.equal(gender.getType(), 'http://gedcomx.org/Male');
24
    assert.equal(gender.getConfidence(), 'http://gedcomx.org/High');
25
    assert.equal(gender.getAttribution().getCreated().getTime(), 1145667891);
26
  });
27
  
28
  it('Build', function(){
29
    var gender = GedcomX.Gender()
30
      .setId('gender')
31
      .setType('http://gedcomx.org/Female')
32
      .setConfidence('http://gedcomx.org/High')
33
      .setAttribution({
34
        created: 1145667891
35
      });
36
    assert.equal(gender.getId(), 'gender');
37
    assert.equal(gender.getType(), 'http://gedcomx.org/Female');
38
    assert.equal(gender.getConfidence(), 'http://gedcomx.org/High');
39
    assert.equal(gender.getAttribution().getCreated().getTime(), 1145667891);
40
  });
41
  
42
  it('toJSON', function(){
43
    var genderData = {
44
        id: 'gender',
45
        type: 'http://gedcomx.org/Male',
46
        confidence: 'http://gedcomx.org/High',
47
        attribution: {
48
          created: 1145667891
49
        }
50
      }, gender = GedcomX.Gender(genderData);
51
    assert.deepEqual(gender.toJSON(), genderData);
52
  });
53
  
54
  it('constructor does not copy instances', function(){
55
    var obj1 = GedcomX.Gender();
56
    var obj2 = GedcomX.Gender(obj1);
57
    assert.strictEqual(obj1, obj2);
58
  });
59
  
60
});